﻿using GoogleSheetsWrapper;

namespace AI.Demo.RoomsAnalyzeTool.Models
{
    public class GSheetRecord : BaseRecord
    {
        public override string ToString()
        {
            return $"<{Env}-{IncidentId}-{CreationTime}>[{Company}:{RoomName}]";
        }

        public GSheetRecord()
        {
        }

        public GSheetRecord(IList<object> row, int rowId, int minColumnId = 1)
            : base(row, rowId, minColumnId)
        {
        }

        [SheetField(DisplayName = "Env", ColumnID = 1, FieldType = SheetFieldType.String)]
        public string Env { get; set; } = "Init";

        [SheetField(DisplayName = "Status", ColumnID = 2, FieldType = SheetFieldType.String)]
        public string Status { get; set; } = "Init";

        [SheetField(DisplayName = "Incident ID", ColumnID = 3, FieldType = SheetFieldType.String)]
        public string IncidentId { get; set; } = "--";

        [SheetField(DisplayName = "Creation Time", ColumnID = 4, FieldType = SheetFieldType.String)]
        public string CreationTime { get; set; } = "--";

        [SheetField(DisplayName = "Client Version", ColumnID = 5, FieldType = SheetFieldType.String)]
        public string ClientVersion { get; set; } = "--";

        [SheetField(DisplayName = "Branch", ColumnID = 6, FieldType = SheetFieldType.String)]
        public string Branch { get; set; } = "--";

        [SheetField(DisplayName = "Device", ColumnID = 7, FieldType = SheetFieldType.String)]
        public string Device { get; set; } = "--";

        [SheetField(DisplayName = "Virtual Memory (Commit/Limit)(Mb)", ColumnID = 8, FieldType = SheetFieldType.String)]
        public string VirtualMemory { get; set; } = "--";

        [SheetField(DisplayName = "Physical Memory (Available/Total)(Mb)", ColumnID = 9, FieldType = SheetFieldType.String)]
        public string PhysicalMemory { get; set; } = "--";

        [SheetField(DisplayName = "Company", ColumnID = 10, FieldType = SheetFieldType.String)]
        public string Company { get; set; } = "--";

        [SheetField(DisplayName = "Room Name", ColumnID = 11, FieldType = SheetFieldType.String)]
        public string RoomName { get; set; } = "--";

        [SheetField(DisplayName = "Account ID", ColumnID = 12, FieldType = SheetFieldType.String)]
        public string AccountID { get; set; } = "--";

        [SheetField(DisplayName = "User ID", ColumnID = 13, FieldType = SheetFieldType.String)]
        public string UserID { get; set; } = "--";

        [SheetField(DisplayName = "Fix Plan", ColumnID = 14, FieldType = SheetFieldType.String)]
        public string FixPlan { get; set; } = "--";

        [SheetField(DisplayName = "Cpr Type", ColumnID = 15, FieldType = SheetFieldType.String)]
        public string CprType { get; set; } = "--";

        [SheetField(DisplayName = "Is Simulated", ColumnID = 16, FieldType = SheetFieldType.Boolean)]
        public bool IsSimulated { get; set; }

        [SheetField(DisplayName = "Tracker", ColumnID = 17, FieldType = SheetFieldType.String)]
        public string Tracker { get; set; } = "--";

        [SheetField(DisplayName = "Call Stack", ColumnID = 18, FieldType = SheetFieldType.String)]
        public string CallStack { get; set; } = "--";

        [SheetField(DisplayName = "Root Cause", ColumnID = 19, FieldType = SheetFieldType.String)]
        public string RootCause { get; set; } = "--";

        [SheetField(DisplayName = "Comments", ColumnID = 20, FieldType = SheetFieldType.String)]
        public string Comments { get; set; } = "--";

        [SheetField(DisplayName = "CPR Link", ColumnID = 21, FieldType = SheetFieldType.String)]
        public string CPRLink { get; set; } = "--";

        [SheetField(DisplayName = "Last\r\nCommit Id", ColumnID = 22, FieldType = SheetFieldType.String)]
        public string LastCommitId { get; set; } = "--";

        [SheetField(DisplayName = "Last\r\nUpdate Time", ColumnID = 23, FieldType = SheetFieldType.String)]
        public string LastUpdateTime { get; set; } = "--";

        [SheetField(DisplayName = "Is Analyzed", ColumnID = 24, FieldType = SheetFieldType.Boolean)]
        public bool IsAnalyzed { get; set; }

        [SheetField(DisplayName = "Exception Info", ColumnID = 25, FieldType = SheetFieldType.String)]
        public string ExceptionInfo { get; set; } = "--";

        [SheetField(DisplayName = "No Symbols List", ColumnID = 26, FieldType = SheetFieldType.String)]
        public string NoSymbols { get; set; } = "--";
    }

    public class GSheetRepository : BaseRepository<GSheetRecord>
    {
        public GSheetRepository()
        {
        }

        public GSheetRepository(SheetHelper<GSheetRecord> sheetsHelper, BaseRepositoryConfiguration config)
            : base(sheetsHelper, config)
        {
        }
    }
}